package com.diversitopia.report;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Utils {
	private static final String standardFormat = "MMM dd, yyyy";

	public static Date parseDate(String date) {
		return parseDate(date, standardFormat);
	}

	public static Date parseDate(String date, String format) {
		DateFormat df = new SimpleDateFormat(format);
		try {
			return df.parse(date);
		} catch (ParseException e) {
			return new Date();
		}
	}

	public static String formatDate(Date date, String dateFormat) {
		DateFormat df = new SimpleDateFormat(dateFormat);
		return df.format(date);
	}
}
